import { createPinia, defineStore } from "pinia";
import { ref, computed } from "vue";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate"; // 所有 Store 都开启持久化存储
import { routerMap } from "../router/routerMap.js";
const pinia = createPinia(); // 创建一个 Pinia 实例
pinia.use(piniaPluginPersistedstate); // 使用 pinia-plugin-persistedstate 插件
export const useStore = defineStore("myStore", {
  state: () => {
    return {
      token: "token",
      userInfo: {
        name: "chaozhang",
      },
      menuList: [...routerMap],
      routerLoading: false, //路由加载loading
      apiLoading: false, //接口loading,
      tabNavList: [], //tab页面切换
    };
  },
  getters: {},
  actions: {},
  // 使用该插件，开启数据缓存
  persist: true,
});
export default pinia;
